<?php require_once '../global.php';

require_once('key_db_class.php');

/**
	添加留言
*/
function king_def(){
	global $king;

/*
 $badkey = "敏感词A|敏感词B|敏感词C";    
    $string = "敏感词A万岁,我要发表";    
    if(preg_match("/$badkey/i",$string)){    
            echo "对不起，含有敏感字符，不允许发表";    
   }else{    
         //do something...    
         echo "发布成功!";  
   }    
/*
*/






	$kcontent=kc_post('kcontent');

	if(empty($kcontent)){

		
		}else{

					$data=explode(',',$kcontent);
					


					$king->access('portal_express');




					
						foreach($data as $val){
							
							$array=explode(',',keywords_class::k_dangdang_fc($val,3));
							
							$data=$king->db->getRows_number("%s_tag","nshow='0' and ktag in ("._implode($array).")");
					
	 

							if($data >= 1){
									$_array=array(
										'ktitle'=>$val,
										'ktag'=>keywords_class::k_dangdang_fc($val,'2'),
										'kname'=>keywords_class::length($val),
										
										'ndate'=>time(),				
									);

							
									$kid=keywords_class::k_ins_key($_array);
									

									if(!empty($kid)){
										$arrid=keywords_class::k_ins_tag($array,$kid);
										echo '成功添加'.$val.'<br>';
									}

									
							}else{
							echo "关键词不匹配未成功发布";
							}

						}

		}
}





function king_ajax_edt(){
			global $king;
			$king->access('portal_express');
				
				$title=kc_post('ktitle');	
				$data=$_POST;
				$_array=array(
				array('ktitle',0,'添加长尾词关键词'),
				);		
				$s.=kc_htm_hidden(array('but'=>'add'));//这个隐藏域				
				$s.=$king->htmForm('长尾词关键词','<textarea name="ktitle" class="k_in" style="width:400px;height:70px;" ></textarea>',$_array,null,"<tt></tt>");
				$but=kc_htm_a('提交','{URL:\'index.php\',CMD:\'edt\'}');	
				$s.=$GLOBALS['ischeck'];
			if($data['but']=='add' && $GLOBALS['ischeck']){//有密码 并 账号验证成功的时候进行验证
				
		

					$data=explode(',',$title);
					





					
						foreach($data as $val){
							
							$array=explode(',',keywords_class::k_dangdang_fc($val));

									
									$_array=array(
										'ktitle'=>$val,
										'ktag'=>keywords_class::k_dangdang_fc($val),
										'ndate'=>time(),	
										'kname'=>keywords_class::length($val),
									);

								
									$kid=keywords_class::k_ins_key($_array);


									if(!empty($kid)){
										$arrid=keywords_class::k_ins_tag($array,$kid);
										$ds='成功添加'.$val;
									}else{
										$ds=$val.'已经存在';
									}

									
					

						}

					kc_ajax('OK',"<p class=\"k_ok\">".$ds."</p>",1);
			}
		
			kc_ajax('在线咨询',$s,$but,'',570,200);

	}







function king_ajax_fc(){
			global $king;
			$king->access('portal_express');
				
				$title=kc_post('ktitle');	
				$data=$_POST;

				$_array=array(
				array('ktitle',0,'添加分词'),
				);		
				$s.=kc_htm_hidden(array('but'=>'add'));//这个隐藏域				
				
		
				$s.=$king->htmForm('长尾词关键词','<textarea name="ktitle" class="k_in" style="width:400px;height:70px;" ></textarea>',$_array,null,"<tt></tt>");
				$s.=$king->htmForm('过滤','<input type="checkbox" id="nhead" name="nhead" value="1" />');
				$but=kc_htm_a('提交','{URL:\'index.php\',CMD:\'fc\'}');	
				$s.=$GLOBALS['ischeck'];
			if($data['but']=='add' && $GLOBALS['ischeck']){//有密码 并 账号验证成功的时候进行验证
				
		
					$title=str_replace("，",",",$title); 
					$dats=explode(',',$title);


									if(!empty($dats)){
										$arrid=keywords_class::k_ins_fc_tag($dats,$data['nhead']);
										
									}




					kc_ajax('OK',"<p class=\"k_ok\">".$king->lang->get('system/ok/add')."</p>",1);
			}
		
			kc_ajax('分词添加',$s,$but,'',570,200);

	}
















function _implode($arr) {
		return "'".implode("','", (array)$arr)."'";
	}



?>